//
//  SLMessage.m
//  MyChatDemo
//
//  Created by DragonYao on 2017/10/9.
//  Copyright © 2017年 DragonYao. All rights reserved.
//

#import "SLMessage.h"

@implementation SLMessage

- (instancetype)initWithModel:(NSDictionary *)model {
    if (self = [super init]) {
        self.icon = model[@"icon"];
        self.nickname = model[@"nickname"];
        switch ([model[@"type"] integerValue]) {
            case 0:{
                self.msgType = MessageTypeText;
                self.contentText = @"文本";
                break;
            }
            case 1:{
                self.msgType = MessageTypeImage;
                self.picture = [UIImage imageNamed:@""];
                break;
            }
            case 2:{
                self.msgType = MessageTypeAudio;
                self.voiceData = model[@"data"];
                self.voiceTime = model[@"voiceTime"];
                break;
            }
            case 3:{
                self.msgType = MessageTypeVideo;
                self.contentText = @"balabak";
                break;
            }
                
            default:
                break;
        }
    }
    return self;
}

@end
